home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE21
/
EX6.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
2KB
|
49 lines
#include <genstub.c>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static char szSaveEnvVar[128];
switch (uMsg)
{
case WM_CREATE:
GetEnvironmentVariable( "Test", szSaveEnvVar, MAX_PATH + 1 );
return DefWindowProc( hWnd, uMsg, wParam, lParam );
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST: // Sets Env Var "Test" to token on command line.
{
char szMessage[2*( MAX_PATH + 1 )];
char szCommandLine[256];
LPTSTR lpTemp = NULL;
// Read command line into local buffer.
lstrcpy( szCommandLine, GetCommandLine() );
// Search for extra input after program name.
lpTemp = strstr( szCommandLine, " " );
if (lpTemp)
lpTemp = strtok(lpTemp, " ");
// "Test" is removed from environment if there is no token.
SetEnvironmentVariable( "Test", lpTemp );
// Show change in message box.
wsprintf( szMessage, "'Test' was [%s], New Value=[%s]",
szSaveEnvVar, lpTemp );
MessageBox( hWnd, szMessage,
"Changing Environment Variable", MB_OK );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return (NULL);
}